<%@ page import="cn.fzhui.util.PageList" %>
<%@ page import="cn.fzhui.model.Student" %><%--
  Created by IntelliJ IDEA.
  User: fzhui
  Date: 2020/12/8
  Time: 13:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户管理</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }
    </style>
</head>
<body>
<div class="row" style="margin: 0 auto; width: 1024px">
    <p></p>
    <div class="row">
        <div class="col-lg-2">
            <a href="/store.jsp" class="btn btn-success">新增</a>
        </div>
        <div class="col-lg-5"></div>
        <form action="/index" method="get">
            <div class="col-lg-2">
                <select class="form-control" name="searchType" id="search_type">
                    <option value="number">通过工号查询</option>
                    <option value="name">通过姓名查询</option>
                </select>
            </div>
            <div class="col-lg-2">
                <input name="keyword" id="keyword" type="text" class="form-control" placeholder=""/>
            </div>
            <div class="col-lg-1">
                <button type="submit" class="btn btn-default" id="search_button">查询</button>
            </div>
        </form>
    </div>
    <div class="col-lg-12">
        <table class="table table-striped">
            <thead>
            <tr>
                <td>序号</td>
                <td>工号</td>
                <td>姓名</td>
                <td>性别</td>
                <td>密码</td>
                <td>年龄</td>
                <td>出生日期</td>
                <td>操作</td>
            </tr>

            </thead>
            <tbody>
            <%
                PageList<Student> pageList = (PageList<Student>) request.getAttribute("pageList");
                System.out.println(pageList);
                if (pageList != null) {
                    for (Student student : pageList.getList()) {
            %>
            <tr>
                <td>
                    <%=student.getId()%>
                </td>
                <td>
                    <%=student.getNumber()%>
                </td>
                <td>
                    <%=student.getName()%>
                </td>
                <td>
                    <%=student.getSex()%>
                </td>
                <td>
                    <%=student.getPassword()%>
                </td>
                <td>
                    <%=student.getAge()%>
                </td>
                <td>
                    <%=student.getBirthday()%>
                </td>
                <td>
                    <a href="/edit?id=<%=student.getId()%>" class="btn btn-xs btn-info">编辑</a>
                    <a href="/delete?id=<%=student.getId()%>" class="btn btn-xs btn-danger">删除</a>
                </td>
            </tr>
            <%
                    }
                }
            %>
            </tbody>
        </table>
        <nav aria-label="Page navigation">
            <ul class="pagination">

                <%
                    long totalPage = pageList.getTotalPageNumber();
                    for (int i = 1; i <= totalPage; i++) {
                %>
                <li>
                    <a href="/index?currentPage=<%=i%>">
                        <%=i%>
                    </a>
                </li>
                <%
                    }
                %>

            </ul>
        </nav>
    </div>
</div>
</body>
<script src="js/jquery-3.5.1.slim.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</html>